package com.josework.springhelloworld.dto.user;

import com.josework.springhelloworld.model.User;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.UUID;

@Data
public class UserEditParams {

    private Long id;

    private String username;

    private Date birthday;

    private String sex;

    private String address;

    private LocalDateTime addTime;

    private LocalDateTime updateTime;

    public User copyPropertiesToUser(User user){
        //为null，新增User
        if (user==null){
            user = new User();
            user.setSecretKey(UUID.randomUUID().toString().replace("-",""));
        }
        BeanUtils.copyProperties(this,user);

        return user;

    }



}
